//
//  ViewController.m
//  LiveVideoCoreDemo
//
//  Created by Alex.Shi on 16/3/2.
//  Copyright © 2016年 com.Alex. All rights reserved.
//

#import "ViewController.h"
#import "LiveShowViewController.h"
#import "LivePushViewController.h"
#import "LivePlayURLTableViewController.h"

@interface ViewController (){
    LiveShowViewController* _LiveShowViewController;
    LivePushViewController* _LivePushViewController;
    LivePlayURLTableViewController* _LivePlayViewController;
    UIButton* _startLiveShowButton;
    UIButton* _startLivePushButton;
    UIButton* _startLivePlayButton;
}
@end

@implementation ViewController

-(void) UIInit{
    CGFloat fScreenW = [UIScreen mainScreen].bounds.size.width;
    CGFloat fScreenH = [UIScreen mainScreen].bounds.size.height;
    
    UIImageView *backgroundImg = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [backgroundImg setImage:[UIImage imageNamed:@"bg"]];
    [self.view addSubview:backgroundImg];
    
    CGFloat fStartButtonW = 70;
    CGFloat fStartButtonH = 40;
    CGFloat fStartButtonX = fScreenW/2.0 - fStartButtonW/2.0;
    CGFloat fStartButtonY = fScreenH/2.0 - fStartButtonH/2.0 -100;
    _startLivePushButton = [[UIButton alloc] initWithFrame:CGRectMake(fStartButtonX, fStartButtonY, fStartButtonW, fStartButtonH)];
    _startLivePushButton.backgroundColor = [UIColor blueColor];
    _startLivePushButton.layer.masksToBounds = YES;
    _startLivePushButton.layer.cornerRadius  = 5;
    [_startLivePushButton setTitle:@"主播模式" forState:UIControlStateNormal];
    [_startLivePushButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _startLivePushButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:10];
    [_startLivePushButton addTarget:self action:@selector(onStartLivePushClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_startLivePushButton];
    
    fStartButtonY += 50;
    _startLivePlayButton = [[UIButton alloc] initWithFrame:CGRectMake(fStartButtonX, fStartButtonY, fStartButtonW, fStartButtonH)];
    _startLivePlayButton.backgroundColor = [UIColor blueColor];
    _startLivePlayButton.layer.masksToBounds = YES;
    _startLivePlayButton.layer.cornerRadius  = 5;
    [_startLivePlayButton setTitle:@"粉丝模式" forState:UIControlStateNormal];
    [_startLivePlayButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _startLivePlayButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:10];
    [_startLivePlayButton addTarget:self action:@selector(onStartLivePlayClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_startLivePlayButton];
    
    fStartButtonY += 50;
    _startLiveShowButton = [[UIButton alloc] initWithFrame:CGRectMake(fStartButtonX, fStartButtonY, fStartButtonW, fStartButtonH)];
    _startLiveShowButton.backgroundColor = [UIColor blueColor];
    _startLiveShowButton.layer.masksToBounds = YES;
    _startLiveShowButton.layer.cornerRadius  = 5;
    [_startLiveShowButton setTitle:@"主播＋粉丝" forState:UIControlStateNormal];
    [_startLiveShowButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _startLiveShowButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:10];
    [_startLiveShowButton addTarget:self action:@selector(onStartLiveShowClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_startLiveShowButton];
}

-(void)onStartLivePushClicked:(id)sender{
    _LivePushViewController = [[LivePushViewController alloc] init];
    [_LivePushViewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [self presentViewController:_LivePushViewController animated:YES completion:^{
        
    }];
}

-(void)onStartLivePlayClicked:(id)sender{
    _LivePlayViewController = [[LivePlayURLTableViewController alloc] init];
    [_LivePlayViewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [self presentViewController:_LivePlayViewController animated:YES completion:^{
        
    }];
}

-(void)onStartLiveShowClicked:(id)sender{
    _LiveShowViewController = [[LiveShowViewController alloc] init];
    [_LiveShowViewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [self presentViewController:_LiveShowViewController animated:YES completion:^{
        
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    [self UIInit];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
